<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>项目管理系统</title>
<link rel="stylesheet" rev="stylesheet" href="../css/style.css" type="text/css" media="all" />
<script src="../../js/jquery1.9.js"></script>
<script src="../../js/jquery.form.js"></script>
<script src="../../js/urlParams.js"></script>
<script charset="utf-8" src="../../js/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="../../js/kindeditor/lang/zh_CN.js"></script>
<script charset="utf-8" src="../../js/kindeditor/style/complex.js"></script>
<style type="text/css">
<!--
.atten {font-size:12px;font-weight:normal;color:#F00;}
-->
</style>
</head>

<body class="ContentBody">
 <form id="form_id" >
<div class="MainDiv">
<table width="99%" border="0" cellpadding="0" cellspacing="0" class="CContent">
  <tr>
      <th class="tablestyle_title" >新闻行业动态修改页面</th>
      <input type="hidden" name="id" id="news_id"/>
  </tr>
  <tr>
    <td class="CPanel">
		
		<table border="0" cellpadding="0" cellspacing="0" style="width:100%">
		<TR>
			<TD width="100%">
				<fieldset style="height:100%;">
				<legend>修改新闻</legend>
					  <table border="0" cellpadding="2" cellspacing="1" style="width:100%">
					 
					  <tr>
					    <td nowrap align="right" width="13%">新闻(行业动态)标题:</td>
					    <td width="41%"><input id="news_title" name="title" class="text" style="width:250px" type="text" size="40" />
				        <span class="red"> *</span></td>
					    </tr>
					    
					   <tr>
					    	<td nowrap align="right" width="13%">类型:</td>
					    	<td width="41%">
						    	<select name="type" id="news_type_id">
						    		<option value="0">新闻</option>
						    		<option value="1">行业动态</option>
						    	</select>
					   		</td>
					   </tr>
					   
					   
					  <tr>
					    <td nowrap align="right" height="120px">新闻内容:</td>
					    <td colspan="3">
			    			<textarea id="news_content" name="content" style="width:700px;height:200px;visibility:hidden;"></textarea>
					    </td>
					    </tr>
					  </table>
			 <br />
				</fieldset>			</TD>
		</TR>
		
		</TABLE>
	 </td>
  </tr>
		<TR>
			<TD colspan="2" align="center" height="50px">
			<input type="button" id="save_input" name="Submit" value="修改" class=""/>　
			
			<input id="backList_id" type="button" name="Submit2" value="返回列表" class=""/></TD>
		</TR>
		</TABLE>
	
	
	 </td>
  </tr>
  </table>

</div>
</form>

<script>
	$(function(){
		jQuery.ajax( {  
			          type : 'get',  
			          contentType : 'application/json',  
			          url : '../../news/get.do',  
			          dataType : 'json',  
			          data:"id="+$.request.queryString["id"],
			          success : function(obj) {  
		          		$("#news_id").val(obj.news.id);
		          		$("#news_title").val(obj.news.title);
		          		$("#news_type_id").val(obj.news.type);
		          		editor.html(obj.news.content);
			          },  
			          error : function(data) {  
			            alert("error")  
			          }  
		         }); 
	});

	$('#save_input').click(
			function() {
				var btnObj = $(this);
				
				if($('#news_title').val() == ''){
				  	alert('请输入标题');
				  	return;
				} else{
					$(this).attr('disabled',true);
					$(this).val('修改中...');
				}
				 var content = editor.html();
				 jQuery.ajax( {  
			          type:'POST', 
			          url : '../../news/edit.do', 
			          dataType : 'json',   
			          data :{id:$("#news_id").val(),content:content,title:$('#news_title').val(),type:$('#news_type_id').val()},
			          success : function(obj) { 
			          	btnObj.val('修改成功');
			          	alert('修改成功!');
			          	location.href="listnews.htm?currPage=1";
			          } ,
			          error:function(){
			          	alert('error');
			          }
		         });  
			});
			
	$('#backList_id').click(function(){
		location.href="listnews.htm?currPage=1";
	});
</script>
</body>
</html>
